<template>
	<view>
		<view class="box">
			<u--form labelPosition="left" ref="uForm" :labelWidth="100">
				<u-form-item label="店铺名称" borderBottom>
					<view class="countBox2">{{notesData.storeName}}</view>
				</u-form-item>
				<u-form-item label="公司名称" borderBottom>
					<view class="countBox2">{{notesData.comName}}</view>
				</u-form-item>
				<u-form-item label="申请人姓名" borderBottom>
					<view class="countBox2">{{notesData.name}}</view>
				</u-form-item>
				<u-form-item label="申请人电话" borderBottom>
					<view class="countBox2" border="none">{{notesData.phone}}</view>
				</u-form-item>
				<u-form-item label="区/县" borderBottom>
					<view class="countBox2">
						{{notesData.countyName}}
					</view>
				</u-form-item>
				<u-form-item label="店铺地址" borderBottom>
					<view class="countBox2">{{notesData.storeAddress}}</view>
				</u-form-item>
				<u-form-item label="社会信用代码" borderBottom>
					<view class="countBox2">{{notesData.creditCode}}</view>
				</u-form-item>
				<!-- <u-form-item label="店铺内桌数" borderBottom >
					<view class="countBox2">{{model1.info.deskNum}}</view>
				</u-form-item> -->
				<u-form-item label="是否省外商家" borderBottom>
					<view class="countBox2" v-if="notesData.isOutsideProvince">
						是
					</view>
					<view class="countBox2" v-else>
						否
					</view>
				</u-form-item>
				<u-form-item :borderBottom='false' label="营业执照">
				</u-form-item>
				<view class="imgBox">
					<uni-file-picker
						v-model="businessLicenseFile"
						:readonly="true"
						return-type="object">
					</uni-file-picker>
				</view>
				<view class="held">

				</view>
				<u-form-item label="商铺门牌照" :borderBottom='false'>
				</u-form-item>
				<view class="imgBox">
					<uni-file-picker
						v-model="facadeFile"
						:readonly="true"
						return-type="object">
					</uni-file-picker>
				</view>
				<view class="held">

				</view>
				<u-form-item label="商铺内景照" :borderBottom='false'>
				</u-form-item>
				<view class="imgBox">
					<uni-file-picker
						v-model="internalFile"
						:readonly="true"
						return-type="object">
					</uni-file-picker>
				</view>
				<view class="held">

				</view>
			</u--form>
			<view class="otherBox">
				<view class="otherTitle">
					审核记录
				</view>
				<view class="other">
					<u-steps :current="1" direction="column">
						<u-steps-item title="发起申请" :desc="notesData.createTime">
						</u-steps-item>
						<u-steps-item v-if="notesData.processStatus==0" title="审核中" :desc="notesData.processTime">
						</u-steps-item>
						<u-steps-item v-if="notesData.processStatus==1" title="审核通过" :desc="notesData.processTime">
						</u-steps-item>
						<u-steps-item v-if="notesData.processStatus==2" error title="审核失败" :desc="notesData.processTime"></u-steps-item>
					</u-steps>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		areaTree
	} from "@/api/wine/wine.js"
	import {
		businessGet
	} from "@/api/work/work.js"
	import common from "@/components/time/time.js"
	export default {
		data() {
			return {
				notesId: '', //业务员id
				notesData: {}, //获取到的数据
				countNmae: '', //区县数据
				businessLicenseFile: [],
				facadeFile: [],
				internalFile: [],
			}
		},
		onLoad(e) {
			if (e.id) {
				this.notesId = e.id
				this.getNotesD()
			}
		},
		methods: {
			//获得记录详情
			getNotesD() {
				let that = this
				uni.showLoading({
					title: '加载中',
				})
				businessGet(that.notesId).then(response => {
					uni.hideLoading()
					that.notesData = response.data
					that.notesData.createTime = common.tiem(that.notesData.createTime)
					that.notesData.processTime = common.tiem(that.notesData.processTime)
					that.businessLicenseFile = that.convertUrlToFileObj(that.notesData.businessLicenseUrl)
					that.facadeFile = that.convertUrlToFileObj(that.notesData.facadeUrl)
					that.internalFile = that.convertUrlToFileObj(that.notesData.internalUrls)
					// this.getArea()
				})
			},
			// 处理URL转换为文件对象
			convertUrlToFileObj(url) {
				if(!url) return [];
				if(Array.isArray(url)) {
					return url.map(item => {
						const name = item.split('/').pop();
						const extname = name.split('.').pop();
						return {
							name,
							extname,
							url: item
						};
					});
				}
				const name = url.split('/').pop();
				const extname = name.split('.').pop();
				return [{
					name,
					extname,
					url
				}];
			},
			// //获得区县数据
			// getArea() {
			// 	let that = this
			// 	uni.showLoading({
			// 		title: '加载中',
			// 	})
			// 	areaTree().then(response => {
			// 		that.countNmae = that.findAndConcatenate(response.data,that.notesData.county)
			// 	})
			// },
			// 处理数据
			// findAndConcatenate(data, id, currentResult = '') {
			//   for (let item of data) {
			//     if (item.id === id) {
			//       // 如果找到匹配的id，返回拼接的字符串
			//       return currentResult + item.name;
			//     }
			//     if (item.children && item.children.length > 0) {
			//       // 递归查找子节点
			//       let result = this.findAndConcatenate(item.children, id, currentResult + item.name);
			//       if (result) {
			//         // 如果在子节点中找到了id，返回拼接后的字符串
			// 		uni.hideLoading()
			//         return result;
			//       }
			//     }
			//   }
			//   uni.hideLoading()
			//   return '';
			// }
		}
	}
</script>

<style>
	page {
		background-color: white;
	}

	.box {
		width: 690rpx;
		height: fit-content;
		margin: 20rpx auto;
		padding-bottom: 100rpx;
	}

	.imgBox {
		width: 690rpx;
		padding-bottom: 20rpx;
		height: fit-content;
		display: flex;
		flex-wrap: wrap;
	}

	.busImg {
		width: 300rpx;
		height: 200rpx;
	}

	.busImg1 {
		width: 400rpx;
		height: 300rpx;
	}

	.held {
		width: 100%;
		height: 2rpx;
		background-color: #F1F1F1;
	}

	.countBox2 {
		width: 80%;
		/* height: 100%; */
		margin-left: 30rpx;
	}

	.otherBox {
		width: 690rpx;
		height: 300rpx;
		/* background-color: red; */
		margin-top: 30rpx;
		display: flex;
		justify-content: space-between;
	}

	.otherTitle {
		width: 120rpx;
		height: 300rpx;
		font-size: 28rpx;
		color: #404040;
	}

	.other {
		width: 500rpx;
		height: 300rpx;
	}
</style>